package com.matt.docpro.service;

import com.matt.docpro.mapper.CheckinMapper;
import com.matt.docpro.mapper.PatientMapper;
import com.matt.docpro.mapper.UserMapper;
import com.matt.docpro.model.Checkin;
import com.matt.docpro.model.Patient;
import com.matt.docpro.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * AppointmentService
 * Created by on 2024/02/20.
 */
@Service
public class CheckinService {

    @Autowired
    CheckinMapper checkinMapper;
    @Autowired
    UserMapper userMapper;

    public List<Checkin> getAll() {
        return checkinMapper.getAll();
    }

    public Checkin getById(String id) {
        return checkinMapper.getById(id);
    }

    public int getCount() {
        return checkinMapper.getCount();
    }

    public void update(Checkin checkin) {
        checkinMapper.update(checkin);
    }

    public void insert(Checkin checkin) {
        checkinMapper.insert(checkin);
        User user = new User();
        user.setId(checkin.getId());
        user.setPassword("123456");
        user.setAccount(checkin.getId());
        user.setMail(checkin.getMail());
        user.setBaned(false);
        user.setRole("3");
        userMapper.insert(user);
    }

}
